const baseUrl = '/tz';

const modelAction = [
    'MODEL_QUERY_ALL_INFO',
    'MODEL_QUERY_ALL_INFO_BY_PAGE',
    'MODEL_QUERY_ALL',
    'MODEL_QUERY_INFO_BY_PAGE',
    'MODEL_QUERY_BY_PAGE',
    'MODEL_LIST_ALL_BY_PAGE',
    'MODEL_QUERY',
    'MODEL_QUERY_ALL_VERSION_INFO_BY_PAGE',
    'MODEL_QUERY_VERSION_INFO_BY_PAGE',
    'MODEL_QUERY_VERSION',
    'MODEL_SET_PUBLISH',
    'MODEL_SET_UN_PUBLISH',
    'MODEL_UPGRADE',
    'MODEL_ADD',
    'MODEL_QUERY_BY_IDS',
    'MODEL_CLONE',
    'MODEL_UPDATE_CLASSNAME',
    'MODEL_UPDATE_BY_ID',
    'MODEL_DELETE_BY_IDS',
    'MODEL_DELETE_BY_CLASSNAME',
    'MODEL_DELETE_BY_CLASSNAMES',
    'MODEL_REPEAL_BY_IDS',
    'MODEL_REPEAL_BY_CLASSNAMES',
    'MODEL_QUERY_HIER_PROPERTIES',
    'MODEL_UPDATE_HIER_PROPERTIES',
]
const instanceAction = [
    'INSTANCE_QUERY_ALL_INFO',
    'INSTANCE_QUERY_ALL_INFO_BY_PAGE',
    'INSTANCE_QUERY_ALL',
    'INSTANCE_QUERY_INFO_BY_PAGE',
    'INSTANCE_QUERY_BY_PAGE',
    'INSTANCE_LIST_ALL_BY_PAGE',
    'INSTANCE_QUERY',
    'INSTANCE_QUERY_BY_IDS',
    'INSTANCE_ADD',
    'INSTANCE_ADD_AND_INIT_WEB',
    'INSTANCE_BATCH_ADD',
    'INSTANCE_UPDATE_BY_ID',
    'INSTANCE_UPDATE_BY_IDS',
    'INSTANCE_UPDATE_CLASSNAME',
    'INSTANCE_DELETE_BY_IDS',
    'INSTANCE_DELETE_BY_CONDITION',
    'INSTANCE_DELETE_BY_CLASSNAME',
    'INSTANCE_DELETE_BY_CLASSNAMES',
    'INSTANCE_REPEAL_BY_IDS',
    'INSTANCE_REPEAL_BY_CLASSNAMES',
    'INSTANCE_QUERY_HIER_BY_ID',
    'INSTANCE_UPDATE_HIER',
]

const controller=[
    //#region model
    {name:'RoutingConfiguration',model:'routing',path:'model', prefix: 'ROUTING_', action:[
        ...modelAction,
    ]},
    {name:'RoutingInstance',model:'routing',path:'instance', prefix: 'ROUTING_', action:[
        ...instanceAction,
        'INSTANCE_START_ROUTING'
    ]},
    {name:'WorkCenterConfiguration',model:'workCenter',path:'model', prefix: 'WORK_CENTER_', action:[
        ...modelAction,
    ]},
    {name:'WorkCenterInstance',model:'workCenter',path:'instance', prefix: 'WORK_CENTER_', action:[
        ...instanceAction,
        'INSTANCE_QUERY_ALL_BY_PARENT_NODE_ID'
    ]},
    {name:'TwinsConfiguration',model:'twins',path:'model', prefix: 'TWINS_', action:[
        ...modelAction
    ]},
    {name:'TwinsInstance',model:'twins',path:'instance', prefix: 'TWINS_', action:[
        ...instanceAction
    ]},
    {name:'TemplateConfiguration',model:'template',path:'model', prefix: 'TEMPLATE_', action:[
        ...modelAction
    ]},
    {name:'TemplateInstance',model:'template',path:'instance', prefix: 'TEMPLATE_', action:[
        ...instanceAction
    ]},
    {name:'ConsumeConfiguration',model:'consume',path:'model', prefix: 'CONSUME_', action:[
        ...modelAction,
    ]},
    {name:'ConsumeInstance',model:'consume',path:'instance', prefix: 'CONSUME_', action:[
        ...instanceAction
    ]},
    {name:'ResourceConfiguration',model:'resource',path:'model', prefix: 'RESOURCE_', action:[
        ...modelAction,
    ]},
    {name:'ResourceInstance',model:'resource',path:'instance', prefix: 'RESOURCE_', action:[
        ...instanceAction
    ]},
    {name:'StatisticsConfiguration',model:'statistics',path:'model', prefix: 'STATISTICS_', action:[
        ...modelAction,
    ]},
    {name:'StatisticsInstance',model:'statistics',path:'instance', prefix: 'STATISTICS_', action:[
        ...instanceAction
    ]},
    {name:'LogicConfiguration',model:'logic',path:'model', prefix: 'LOGIC_', action:[
        ...modelAction,
    ]},
    {name:'LogicInstance',model:'logic',path:'instance', prefix: 'LOGIC_', action:[
        ...instanceAction
    ]
    },
    {
        name: 'Documents', model: 'documents', path: '', prefix: 'DOCUMENTS_', action: [
        'QUERY_ALL_INFO',
        'QUERY_ALL_INFO_BY_PAGE',
        'QUERY_ALL',
        'QUERY_INFO_BY_PAGE',
        'QUERY_BY_PAGE',
        'LIST_ALL_BY_PAGE',
        'QUERY',
        'QUERY_BY_IDS',
        'ADD',
        'BATCH_ADD',
        'UPDATE_BY_ID',
        'UPDATE_BY_IDS',
        'UPDATE_CLASSNAME',
        'DELETE_BY_IDS',
        'DELETE_BY_CLASSNAME',
        'DELETE_BY_CLASSNAMES',
        'REPEAL_BY_IDS',
        'REPEAL_BY_CLASSNAMES',
        'QUERY_HIER_BY_ID',
        'UPDATE_HIER',
    ]},
    {name:'StaticLogicConfiguration',model:'staticLogic',path:'model', prefix: 'STATIC_LOGIC_', action:[
        ...modelAction,
    ]},
    {name:'StaticLogicInstance',model:'staticLogic',path:'instance', prefix: 'STATIC_LOGIC_', action:[
        ...instanceAction,
    ]},
    {name:'TankConfiguration',model:'tank',path:'model', prefix: 'TANK_', action:[
        ...modelAction,
    ]},
    {name:'TankInstance',model:'tank',path:'instance', prefix: 'TANK_', action:[
        ...instanceAction
    ]},
    // #endregion

    //#region basic
    {name:'EventManage',model:'event', prefix: 'EVENT_', action:[
        'ADD',
        'UPDATE',
        'DELETE_BY_IDS',
        'QUERY',
        'QUERY_INFO_BY_PAGE',
        'BATCH_ADD',
        'BATCH_UPDATE',
        'BATCH_DELETE',
        'DELETE',
        'QUERY_INCLUDE_UNPU',
        'QUERY_INFO_INCLUDE',
        'QUERY_INFO',
        'QUERY_BY_IDS',
        'QUERY_BY_PAGE',
    ]},
    {name:'ApiConfig',model:'api/config', prefix: 'API_CONFIG_', action:[
        'ADD',
        'BATCH_ADD',
        'UPDATE',
        'BATCH_UPDATE',
        'DELETE',
        'BATCH_DELETE',
        'DELETE_BY_IDS',
        'QUERY',
        'QUERY_INFO_BY_PAGE',
        'QUERY_INFO_INCLUDE',
        'QUERY_INFO',
        'QUERY_BY_IDS',
        'QUERY_BY_PAGE',
    ]},
    {name:'ConfigManage',model:'config', prefix: 'CONFIG_', action: [
        'ADD',
        'DELETE',
        'BATCH_UPDATE',
        'DELETE_BY_IDS',
        'UPDATE',
        'QUERY',
        'QUERY_INFO',
        'QUERY_BY_PAGE',
    ]},
    {name:'ListByIds',model:'config',path:'listByIds'},
    {name:'infConfig',model:'infConfig', prefix: 'INF_CONFIG_', action: [
        'UPDATE',
        'QUERY',
        'ADD',
        'DELETE_BY_IDS',
    ]},
    //#endregion

    //#region system
    {name:'ModelManage',model:'bsl',path:'getAllModel'},
    {name:'ModeInfolManage',model:'bsl',path:'getAllModelInfo'},
    {name:'AccountLogin',model:'auth',path:'login'},
    {name:'AccountManage',model:'auth',path:'user', prefix: 'USER_ACCOUNT_', action: [
        'ADD',
        'DELETE',
        'DELETE_BY_ID',
        'DELETE_BY_IDS',
        'BATCH_UPDATE',
        'UPDATE',
        'DELETE_BY_ID',
        'QUERY_BY_IDS',
        'QUERY_BY_PAGE',
    ]},
    {name:'AccountRoleManage',model:'auth',path:'accountRole', prefix: 'ACCOUNT_ROLE_', action: [
        'ADD',
        'DELETE',
        'BATCH_UPDATE',
        'DELETE_BY_IDS',
        'UPDATE',
        'QUERY',
        'FIRST_DELETE_ADD',
    ]},
    {name:'MenuManage',model:'auth',path:'menu', prefix: 'MENU_', action: [
        'ADD',
        'DELETE',
        'DELETE_BY_ID',
        'DELETE_BY_IDS',
        'BATCH_DELETE',
        'UPDATE',
        'QUERY',
    ]},
    {name:'MenuByUserId',model:'auth',path:'menuByUserId'},
    {name:'PrivilegeManage',model:'auth',path:'privilege', prefix: 'PRIVILEGE_', action: [
        'ADD',
        'DELETE',
        'BATCH_UPDATE',
        'DELETE_BY_IDS',
        'UPDATE',
        'QUERY',
        'FIRST_DELETE_ADD',
    ]},
    {name:'RoleManage',model:'auth',path:'role', prefix: 'ROLE_', action: [
        'ADD',
        'DELETE',
        'DELETE_BY_ID',
        'DELETE_BY_IDS',
        'BATCH_DELETE',
        'UPDATE',
        'QUERY',
        'QUERY_BY_PAGE',
    ]},
    {name:'RolegpManage',model:'auth',path:'rolegp', prefix: 'ROLEGP_', action: [
        'ADD',
        'DELETE',
        'DELETE_BY_ID',
        'DELETE_BY_IDS',
        'BATCH_DELETE',
        'UPDATE',
        'QUERY_BY_PAGE',
    ]},
    {name:'RolegpRoleManage',model:'auth',path:'rolegpRole', prefix: 'ROLEGP_ROLE_', action: [
        'ADD',
        'DELETE',
        'BATCH_UPDATE',
        'DELETE_BY_IDS',
        'UPDATE',
        'QUERY',
        'FIRST_DELETE_ADD',
    ]},
    //#endregion

    //#region function
    {name: 'ListenerManage', modeL:'', path: 'listener', prefix: 'LISTENER_', action: [
        'ADD',
        'DELETE',
        'BATCH_UPDATE',
        'DELETE_BY_IDS',
        'UPDATE',
        'QUERY',
        'QUERY_INFO',
        'QUERY_BY_PAGE',
    ]},
    {name: 'BiInstanceManage', model: '', prefix: 'BI_', action: [
        'INSTANCE_UPDATE',
        'INSTANCE_QUERY',
        'INSTANCE_QUERY_INCLUDE_UNPUBLISHED',
        'INSTANCE_QUERY_BY_PAGE',
        'INSTANCE_QUERY_INFO',
        'INSTANCE_QUERY_INFO_INCLUDE_UNPUBLISHED',
        'INSTANCE_QUERY_INFO_BY_PAGE',
    ]},
    {name:'ComponentManage',model:'component', prefix: 'COMPONENT_', action: [
        'ADD',
        'DELETE',
        'BATCH_UPDATE',
        'DELETE_BY_IDS',
        'UPDATE',
        'QUERY',
        'QUERY_BY_ID',
        'QUERY_BY_IDS',
        'QUERY_INFO',
        'QUERY_CONFIG',
        'QUERY_VALUE',
        'QUERY_BY_PAGE',
    ]},
    {name:'PageViewManage',model:'pageView', prefix: 'PAGE_VIEW_', action: [
        'ADD',
        'DELETE',
        'BATCH_UPDATE',
        'DELETE_BY_IDS',
        'UPDATE',
        'QUERY',
        'QUERY_INFO',
        'QUERY_BY_PAGE',
    ]},
    {name: 'TimerManage',model: 'timer', prefix: 'TIMER_', action: [
        'ADD',
        'DELETE',
        'BATCH_DELETE',
        'DELETE_BY_IDS',
        'UPDATE',
        'QUERY',
        'QUERY_INFO',
        'QUERY_BY_PAGE',
    ]},
    {name:'SimpleMap',model:'simpleMap',path:'', prefix: 'SIMPLE_MAP_', action:[
        'QUERY_INFO_BY_PAGE',
        'QUERY_INFO',
        'DELETE_BY_NAMES',
        'DELETE_BY_IDS',
        'QUERY',
        'UPDATE',
        'ADD',
    ]},
    {name: 'TextureLib', model: 'texture', prefix: 'TEXTURE_', action: [
        'QUERY_INFO_BY_PAGE',
        'QUERY_INFO',
        'QUERY_INFO_ALL',
        'DELETE_BY_NAMES',
        'DELETE_BY_IDS',
        'QUERY',
        'UPDATE',
        'ADD',
    ]},
    {name: 'Bi', model: 'bi', prefix: 'BI_', action: [
        'QUERY_INFO_BY_PAGE',
        'QUERY_INFO',
        'QUERY_INFO_ALL',
        'DELETE_BY_NAMES',
        'DELETE_BY_IDS',
        'DELETE_BY_ID',
        'QUERY',
        'UPDATE',
        'ADD',
    ]},
    {name: 'Mesh', model: 'mesh', prefix: 'MESH_', action: [
        'ADD',
        'BATCH_ADD',
        'UPDATE',
        'BATCH_UPDATE',
        'DELETE',
        'BATCH_DELETE',
        'DELETE_BY_IDS',
        'QUERY',
        'QUERY_BY_NAME',
        'QUERY_BY_NAMES',
        'QUERY_INFO',
        'QUERY_BY_IDS',
        'QUERY_BY_PAGE',
        'QUERY_INFO_BY_PAGE',
        'QUERY_INFO_ALL',
        'DOWNLOAD_FILE_BASE64_BY_NAME',
        'DOWNLOAD_FILE_BASE64_BY_ID',
        'DELETE_FILE_BY_ID',
        'DELETE_FILE_BY_NAME',
        'UPDATE_FILE',
    ]},
    {name: 'MeshUploadFile', model: 'mesh', path: 'uploadFile', action: [
    ]},
    {name: 'MeshDownloadFile', model: 'mesh', path: 'downloadFile', prefix: 'MESH_', action: [
        'DOWNLOAD_FILE_BY_ID',
        'DOWNLOAD_FILE_BY_NAME',
    ]},
    {name: 'Test', model: 'test', path: 'event1', prefix: '', action: [
        'QUERY'
    ]},
    {name: 'Custom', model: 'custom', path: 'path', prefix: '', action: [
    ]},
    {name: 'Business', model: 'business', path: 'eventExecute', prefix: '', action: [
    ]},
    {name: 'CodeGetNextVal', model: 'common', path: 'getNextVal', prefix: '', action: [
    ]},
    {name: 'CodeGetNextValByCode', model: 'common', path: 'getNextValByCode', prefix: '', action: [
    ]},
    {name: 'Hier', model: 'hier', path: 'instance', prefix: 'HIER_', action: [
        'INSTANCE_SAVE_HIER_WITHOUT_MODEL',
        'INSTANCE_DELETE_HIER_BY_ID_LIST',
        'INSTANCE_QUERY_WITH_LINK',
        'INSTANCE_QUERY_BY_PAGE',
        'INSTANCE_QUERY_BY_ID',
        'INSTANCE_QUERY_BY_PAGE_WITH_CONTAINERID'
    ]},
    {name: 'ReportManage', model: 'report', prefix: 'REPORT_', action: [
        'ADD',
        'DELETE',
        'BATCH_DELETE',
        'DELETE_BY_IDS',
        'UPDATE',
        'QUERY',
        'QUERY_INFO',
        'QUERY_BY_PAGE',
    ]},
    {name: 'saleMRP', model: 'custom', path: 'saleMRP', action: []},
    {name: 'monthMRP', model: 'custom', path: 'monthMRP', action: []},
    {
        name: 'UploadFile', model: 'file', path: 'uploadFile', action: [],
        headers: { 'Content-Type': 'multipart/form-data' },
        // multipart/form-data; boundary=----WebKitFormBoundaryvoha61ZeKdcouuR2
    },
    // #endregion
]
function base(model, path, config={}) {
    let url = [baseUrl];

    model && url.push(model);
    path && url.push(path);
    return {
        url: url.join('/'),
        method: 'post',
        data: {},
        ...config
    }
}
function getMap(){
    let map={};
    controller.map(item=>{
        map[item.name]=base(item.model,item.path,item.config)
    });
    return map;
}
function getAction(){
    let map={};
    controller.map(item=>{
        map[item.name]={};
        if(!!item.action){
            let actionPrefix = (item.prefix || '') // 每一个controller，在action中都有前缀；
            item.action.map(a=>
                map[item.name][a] = actionPrefix + a
            )
        }
    });
    return map;
}
export const actionsMap={...getAction()};
export { baseUrl }
export default {...getMap()};

